package br.unifor.mia.graph.setorcensitario;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "momento")
public class Crime {
	
	@Id
	private Integer tempo;
	
	@ManyToOne
	private Link link;

	public Crime() {
		// Usado pelo Hibernate
	}
	
	public Crime(Integer tempo, Link link) {
		this.tempo = tempo;
		this.link = link;
	}
	
	public Integer getTempo() {
		return tempo;
	}

	public Link getLink() {
		return link;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((tempo == null) ? 0 : tempo.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (!(obj instanceof Crime)) {
			return false;
		}
		Crime other = (Crime) obj;
		if (tempo == null) {
			if (other.tempo != null) {
				return false;
			}
		} else if (!tempo.equals(other.tempo)) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "Momento: " + tempo;
	}
	
}
